package org.openintents.droidcon.cloud.mvc;

import java.util.List;

import org.openintents.droidcon.cloud.model.Panel;
import org.openintents.droidcon.cloud.model.Room;
import org.openintents.droidcon.cloud.model.Schedule;
import org.openintents.droidcon.cloud.model.Slot;

public class ScheduleListXml {

	private List<Schedule> schedules;

	public ScheduleListXml(List<Schedule> schedules) {
		this.schedules = schedules;
	}

	public String display() {
		String output = "<scheduleList title=\"droidconcloud\">";
		for (Schedule s : schedules) {
			output += "<schedule id=\"" + s.getName() + "\" location = \""
					+ s.getLocation() + "\" date=\"" + s.getDateString() + "\" version = \"" + s.getVersion() +  "\">";

			output += "<rooms>";
			for (Room r : s.getRooms()) {
				output += "<alias name=\"" + r.getName() + "\" id = \""
						+ r.getAlias() + "\" />";
			}
			output += "</rooms>";

			for (Panel p : s.getPanels()) {
				output += "<panel from=\"" + p.getFromString() + "\" to=\""
						+ p.getToString() + "\">";

				for (Slot slot : p.getSlots()) {
					output += "<slot id=\"" + slot.getTitle() + "\" room_id=\""
							+ slot.getRoomAlias() + "\" speaker=\""
							+ slot.getSpeaker() + "\" description=\""
							+ slot.getDescription() + "\"" + "/>";
				}	
				output += "</panel>";
			}
			output += "</schedule>";

		}
		output += "</scheduleList>";
		return output;
	}
}
